<template>
	<el-dialog draggable overflow v-model="visible" :title="'售后审核'" :width="1000" destroy-on-close
		@closed="$emit('closed')">
		<sk-tabs type="border-card">
			<el-tab-pane ref="tab" label="基础信息">
				<sk-upload v-model="form.attachments" :limit="10" :disabled="true" tip="">
				</sk-upload>

				<el-row>
					<el-col :span="4">
						<el-form-item label="客	户" prop="billdate">
							<el-input v-model="form.customer.name" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="单据日期" prop="billdate">
							<el-date-picker v-model="form.billdate" type="date" placeholder="选择日期" format="YYYY-MM-DD"
								value-format="YYYY-MM-DD" disabled />
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="单号" prop="billdate">
							<el-input v-model="form.code" disabled></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="4">
						<el-form-item label="售后形态" prop="type_id">
							<el-input v-model="form.type.name" disabled></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="4">
						<el-form-item label="售后包数" prop="auxiliary_quantity">
							<el-input v-model="form.auxiliary_quantity" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="售后重量" prop="quantity">
							<el-input v-model="form.quantity" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="单价" prop="price">
							<el-input v-model="form.price" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="售后金额" prop="amount">
							<el-input v-model="form.amount" disabled></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="4">
						<el-form-item label="售后" prop="complaint_id">
							<el-input v-model="form.complaint.name" disabled></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="4">
						<el-form-item label="折扣金额" prop="discount">
							<el-input v-model="form.discount" :disabled="true"
								:placeholder="discountplaceholder"></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="8">
						<el-form-item label="备注" prop="remark">
							<el-input v-model="form.remark" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="缸号" prop="dyelot">
							<el-input v-model="form.dyelot" disabled></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="20">
						<el-form-item label="财务备注" prop="financeremark">
							<el-input v-model="form.financeremark" clearable></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-divider>涉及到退货的库存！</el-divider>
				<sc-VxeTable ref="save" :data="form.details" :gridOps="gridOps"
					:tablecode="'market_complaint_save_finance'">
				</sc-VxeTable>

			</el-tab-pane>
		</sk-tabs>

		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">审 核</el-button>
		</template>
	</el-dialog>
</template>

<script>

import skDicSelect from "@/components/skDicSelect";
import skAutoChoose from "@/components/skAutoChoose";
import XEUtils from "xe-utils";
export default {
	emits: ["success", "closed"],
	components: { skAutoChoose, skDicSelect },
	data() {
		return {
			form: {
				id: "",
				billdate: XEUtils.toDateString(new Date(), "yyyy-MM-dd"),
				location: {},
				customer: { name: "" },
				lot: {},
				type: {},
				color: {},
				details: [],
				attachments: [],
			},

			visible: false,
			isSaveing: false,
			gridOps: {
				height: 205,
			},
		};
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit() {
			this.isSaveing = true;
			this.$API.market.complaint.faudit.post(
				{ id: this.form.id, financeremark: this.form.financeremark }
			).then((res) => {
				if (res.code == 200) {
					this.$emit("success", this.form, this.mode);
					this.visible = false;
					this.$message.success("操作成功");
				}
			}).finally(() => {
				this.isSaveing = false;
			})
		},
		getItems(code) {
			return this.$API.market.complaint.details.post({
				filter: [{ code: code }],
			});
		},
		//表单注入数据
		async setData(data) {
			Object.assign(this.form, this.$TOOL.removeNull(data));
			this.getItems(this.form.code).then((res) => {
				if (res.code == 200) this.form.details = res.data;
			});
		},
	},
};
</script>
